<template>
  <div class="chart"></div>
</template>
    
<script>
import * as echarts from "echarts";

export default {
  name: "casualty",
  data() {
    return {
      chart: null,
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.initChart();
    });
  },
  beforeDestroy() {
    if (!this.chart) {
      return;
    }
    this.chart.dispose();
    this.chart = null;
  },
  methods: {
    initChart() {
      //初始化图表
      this.chart = echarts.init(this.$el);
      //设置图表
      this.chart.setOption({
        series: [
          {
            type: "gauge",
            max:30,
            min:0,
            axisLine: {
              lineStyle: {
                width: 30,
                color: [
                  [0.3, "#67e0e3"],
                  [0.7, "#37a2da"],
                  [1, "#fd666d"],
                ],
              },
            },
            pointer: {
              itemStyle: {
                color: "inherit",
              },
            },
            axisTick: {
              distance: -30,
              length: 8,
              lineStyle: {
                color: "#fff",
                width: 2,
              },
            },
            splitLine: {
              distance: -30,
              length: 30,
              lineStyle: {
                color: "#fff",
                width: 4,
              },
            },
            axisLabel: {
              color: "inherit",
              distance: 40,
              fontSize: 20,
            },
            detail: {
              valueAnimation: true,
              formatter: "{value} 人",
              color: "inherit",
            },
            data: [
              {
                value: 10,
              },
            ],
          },
        ],
      });
    },
  },
};
</script>
  <style scoped>
.chart {
  width: 500px;
  height: 450px;
}
</style>
    